package com.avocado.base.entity;

import lombok.Data;

import java.io.Serializable;
import java.util.Date;
import java.util.Objects;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.TableGenerator;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;



/**
 * 重置密码记录
 * @author xuwenfeng
 *
 */
@Entity
@Table(name="avo_user_password_reset_log")
@Data
public class UserPasswordResetLog implements Serializable{
	
	
	/**
	 * 
	 */
	private static final long serialVersionUID = -4474682021812723888L;

	@Id@Column(name="ID",nullable=false)
	@GeneratedValue(strategy = GenerationType.TABLE,generator="id_gen")
    @TableGenerator(name = "id_gen",pkColumnValue="USER_PASSWORD_RESET_LOG_ID",table="AVO_ID_GENERATOR", pkColumnName="GEN_NAME",valueColumnName="GEN_VALUE",allocationSize=1)
	private Long id;
	
	@ManyToOne(fetch=FetchType.EAGER)@JoinColumn(name="USER_ID")
	private User user;
	
	@Column(nullable=false,name="RESET_PASSWORD")
	private String resetPassword;
	
	
	@Column(name="EMAIL_SEND_BATCH_NO")
	private String emailSendBatchNo;
	
	@Column(name="SMS_SEND_BATCH_NO")
	private String smsSendBatchNo;
	
	
	@Temporal(TemporalType.TIMESTAMP)@Column(nullable=false,name="CREATE_TIME")
	private Date createTime=new Date();
	
	@Temporal(TemporalType.TIMESTAMP)@Column(name="UPDATE_TIME")
	private Date updateTime;
	
	@Temporal(TemporalType.TIMESTAMP)@Column(name="EMAIL_SEND_TIME")
	private Date emailSendTime;
	
	@Temporal(TemporalType.TIMESTAMP)@Column(name="SMS_SEND_TIME")
	private Date smsSendTime;

	public Long getId() {
		return id;
	}

	@Override
	public boolean equals(Object o) {
		if (this == o) return true;
		if (o == null || getClass() != o.getClass()) return false;
		UserPasswordResetLog that = (UserPasswordResetLog) o;
		return Objects.equals(id, that.id);
	}

	@Override
	public int hashCode() {
		return Objects.hash(id);
	}
}
